import { create } from "zustand";
import { persist } from "zustand/middleware";

export interface NewChatStore {
  current: number;
  totol: number;
  gender: number;
  interest: object | null;
  preference: string;
  role: string;
  roleName: string;
  is18: boolean ;
  interestDate:any[];
//   fetchNoticeConfig: (token: string) => Promise<any>;
  selectCurrent: (index: number) => void;
  selectGender: (index: number) => void;
  selectInterest: (obj: object) => void;
  reset: () => void;
}
const DEFAULT_CONFIG = {
  current: 0,
  totol: 4,
  gender: 0,
  interest: null,
  preference: "",
  role: "",
  roleName: "",
  is18: true,
};

const interestDate = [{id:1,avatar:"1f4d1",name:'主导'},{id:2,avatar:"1f469",name:'内敛'},{id:3,avatar:"1f468",name:'调情'},{id:4,avatar:"1f469",name:'逗比'},
{id:5,avatar:"1f469",name:'火辣'},{id:6,avatar:"1f469",name:'可爱'},{id:7,avatar:"1f469",name:'幽默'},{id:8,avatar:"1f469",name:'幽默'},
{id:9,avatar:"1f469",name:'幽默'},{id:10,avatar:"1f469",name:'幽默'},{id:11,avatar:"1f469",name:'诱人'},{id:12,avatar:"1f469",name:'害羞'},
{id:13,avatar:"1f469",name:'幽默'}]

export const useNewChatStore = create<NewChatStore>()(
  persist(
    (set, get) => ({
      current:0, //当前进度
      totol:4, //总进度（个数）
      gender:0, //性别 0其他1男2女
      interest:null,  //兴趣爱好
      preference:'',//偏好
      role:'',  //角色
      roleName:'', //角色名字
      is18:true, //是否满18 
      interestDate:interestDate,

      selectCurrent(index: number) {
        set({
          current: index,
        });
      },
      updateCurrent(newCurrent: number){
        set(()=>({current:newCurrent}))
      },
      reset() {
        set(() => ({ ...DEFAULT_CONFIG }));
      },
      selectGender(index: number) {
        set({
          gender: index,
        });
      },
      
      selectInterest(obj: object) {
        set({
          interest: obj,
        });
      },

  }),{
    name: "new-chat-store",
    // version: 1,
  }
  )
);